<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  手机号：<input type="text" class="tel"><br>
  密码：<input type="text" class="pw"><br>
  <input type="button" value="登录" class="btn">
</body>
<script src="./ajax.js"></script>
<script>

  $(".btn").onclick = function(){
    ajax({
      url:"http://localhost:3000/login",
      data:{
        tel: $(".tel").value,
        password: $(".pw").value
      }
    }).then(res=>{
      res = JSON.parse(res);
      if(res.code === 1){
        localStorage.setItem("token", res.data)
        location.assign("./index.html");
      }
    })
  }

  function $(s){
    return document.querySelector(s);
  }

  // "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc0xvZ2luIjoib2siLCJhYmMiOiJoZWxsbyIsImlhdCI6MTY5NTE5MDc0MCwiZXhwIjoxNjk1MTkwNzYwfQ.r5_pERLJz3L7Hny8vmxJoOBw_7VmBmTqZA5zr86EhhA"
</script>
</html>